package com.fnzn.entranceGuard.rest.usrCloud;

import cn.usr.UsrCloudMqttClientAdapter;
import org.eclipse.paho.client.mqttv3.MqttException;

/**
 * @author sxf
 * @date 2018/05/24 18:58:56
 */
public class ClientAdapter extends UsrCloudMqttClientAdapter {
    public ClientAdapter() {
        super();
    }

    public ClientAdapter(String username, String password) throws Exception {

    }

    @Override
    public void Connect(String userName, String passWord) throws MqttException {
        super.Connect(userName, passWord);
    }

    public static UsrCloudMqttClientAdapter getInstance(String username, String password) throws Exception {
              /* 1.初始化客户端适配 */
        UsrCloudMqttClientAdapter clientAdapter = new ClientAdapter();

    /* 2.初始化客户端回调适配 */
        ClinetCallbackAdapter clinetCallbackAdapter = new ClinetCallbackAdapter();

    /* 3.客户端设置回调 */
        clientAdapter.setUsrCloudMqttCallback(clinetCallbackAdapter);
/**/
    /* 4.进行连接 */
        clientAdapter.Connect(username, password);

        return clientAdapter;
    }
}